package geektime.io.nio2.demo;

import java.io.IOException;
import java.nio.file.*;
import java.nio.file.spi.FileSystemProvider;
import java.util.*;

/**
 * 列出provider的示例
 */
public class ListProvidersDemo {
    public static void main(String[] args) throws IOException {
        System.out.println("打印当前的provider");
        List<FileSystemProvider> providers = FileSystemProvider.installedProviders();
        for (FileSystemProvider provider : providers) {
            System.out.println(provider);
        }
        System.out.println("打印当前的fileStore");
        FileSystem dfFileSystem = FileSystems.getDefault();
        Iterable<FileStore> fileStores = dfFileSystem.getFileStores();
        for (FileStore fileStore : fileStores) {
            System.out.println("fileStore name=" + fileStore.name() + ", totalSpace=" + fileStore.getTotalSpace());
        }
        System.out.println("打印一个路径下的信息");
        Path path = Paths.get("D:\\");
        FileStore fileStore = Files.getFileStore(path);
        System.out.println(fileStore.name());
        System.out.println(fileStore.getTotalSpace());
        System.out.println(fileStore.getUnallocatedSpace());
        System.out.println(fileStore.getUsableSpace());

    }
}
